var express = require('express');
var path = require('path');
var cookieParser = require('cookie-parser');
var logger = require('morgan');

var indexRouter = require('./routes/index');
var usersRouter = require('./routes/users');
var loginRouter = require('./routes/login');
const uploadRouter = require('./routes/upload');
const eventRouter = require('./routes/events');
const noticeRouter = require('./routes/notice');
const viedoRouter = require('./routes/viedo');
const chartRouter = require('./routes/charts');
var cors = require('cors');

var app = express();
app.use(cors());

//配置multer

app.use(logger('dev'));
// app.use('/upload', express.static(path.join(__dirname + '/public')));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use('/images', express.static(path.join(__dirname, 'public/images')));

app.use('/', indexRouter);
app.use('/users', usersRouter);
app.use('/login', loginRouter);
app.use('/upload', uploadRouter);
app.use('/events', eventRouter);
app.use('/charts', chartRouter);
app.use('/notice', noticeRouter);
app.use('/video', viedoRouter);
module.exports = app;
